import Vue from 'vue'
import Message from './Message'

const message = Vue.extend(Message);

Message.install = function (options, type) {
    if (options === undefined || options === null) {
        options = {
            content: ''
        }
    } else if (typeof options === 'string' || typeof options === 'number') {
        options = {
            content: options
        };
        if (type !== undefined && type !== null) {
            options.type = type;
        }
    }

    let instance = new message({
        data: options
    }).$mount();

    document.body.appendChild(instance.$el);

    Vue.nextTick(() => {
        instance.visible = true;
    })
};

export default Message
